﻿<extend name="Public:base" />
<block name="title"><title>个人资料</title></block>
<block name="header_styles">

</block>
<block name="main">
    <div class="row">
        <div class="col-xs-3">
            <div class="column-sidebar">
                <include file="Public:LeftMenu" />
            </div>
        </div>
        <div class="col-xs-9">
            <div class="column-main">
                <div class="section">
                    <div class="section-title">
                        <a href="javascript:void(0);" class="info-actions pull-right" id="btnEditPic" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;头像
                    </div>
                    <div class="section-content">
                        <br />
                        <div id="phPreviewPic">
                            <div class="user-pic">
                                <img src="__APP__/{:toTalentPhoto($userinfo['photo'],$userinfo['utype'])}" alt="" />
                            </div>
                        </div>
                        <div id="phEditablePic" style="display: none;">
                            <iframe src="{:U('/Index/sp')}" scrolling="no" frameborder="0" width="502" height="360" class="photo"></iframe>
                            <input type="hidden" id="userpic" />
                            <div class="text-center" style="padding:10px 0px;">
                                <button type="button" id="btnSavePic" class="btn btn-success">保存头像</button>
                                <br />
                                <br />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="section">
                    <div class="section-title">
                        <a href="javascript:void(0);" class="info-actions pull-right" id="btnEditBaseInfo" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;基本信息
                    </div>
                    <div class="section-content">
                        <br />
                        <div id="phPreviewBaseInfo" class="boroshare-form form-horizontal">
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">邮箱：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static">{$userinfo.email}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">队友及雇主可见</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">真实姓名：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblRealname">{$userinfo.realname}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_realname']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">昵称：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblNickname">{$userinfo.nickname}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">性别：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblGender">
                                                {$userinfo.gender|toGender}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">生日：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static">{$userinfo.birthday|datetimeToStr='Y年m月d日',###}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_birthday']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">工作年限：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblExp">
                                                {$userinfo.exp}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">当前所在地：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblAddress">
                                                {$userinfo.address}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">职业：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblJob">
                                                {$userinfo.job}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">手机：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblMobile">
                                                {$userinfo.mobile}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">队友及雇主可见</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">毕业院校：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblSchool">
                                                {$userinfo.school}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_school']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">所学专业：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblMajor">
                                                {$userinfo.major}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">学历：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblDegress">
                                                <volist name="degrees" id="vo">
                                                    <if condition="($vo.id eq $userinfo['xueli'])">{$vo.name}</if>
                                                </volist>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">擅长领域：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblGoodAt">
                                                <volist name="majors" id="vo">
                                                    <if condition="($vo.id eq $userinfo['shanchang'])">{$vo.name}</if>
                                                </volist>
                                            </p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">博客：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblBlog">
                                                {$userinfo.blog}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_blog']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group">
                                        <label class="control-label col-xs-4">微博：</label>
                                        <div class="col-xs-8">
                                            <p class="form-control-static" id="lblWeibo">
                                                {$userinfo.weibo}
                                            </p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-10 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_weibo']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="phEditableBaseInfo" class="form-horizontal" style="display:none;">
                            <form id="formBaseInfo" method="post">
                                <span class="text-danger" style="padding:10px;">带*号为必填项</span>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">邮箱：</label>
                                            <div class="col-xs-8">
                                                <p class="form-control-static">{$userinfo.email}</p>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">真实姓名：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" name="realname" id="realname"
                                                       data-val="true" data-val-regex="只支持中英文字符和空格" data-val-regex-pattern="([a-zA-Z \\u4e00-\\u9fa5]+)"
                                                       value="{$userinfo.realname}" maxlength="10" />
                                                <span data-valmsg-for="realname" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <select name="f_realname" class="form-control">
                                            <option value="1"<if condition="$priArr['f_realname'] eq 1">selected="selected"</if>>仅自己可见</option>
                                            <option value="2"<if condition="$priArr['f_realname'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                            <option value="3"<if condition="$priArr['f_realname'] eq 3">selected="selected"</if>>所有人可见</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">昵称：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="nickname" name="nickname" data-msg-maxlength="" maxlength="32" data-val="true" data-val-required="昵称不能为空" value="{$userinfo.nickname}"
                                                       data-val-remote="该昵称已存在"
                                                       data-val-remote-url="{:U('Login/signup_checkNicknameAjax')}" />
                                                <span data-valmsg-for="nickname" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*性别：</label>
                                            <div class="col-xs-8">
                                                <select name="gender" id="genderSel" class="form-control" data-val="true" data-val-required="此处必填">
                                                    <if condition="$userinfo.gender eq 1">
                                                        <option value="1" selected>男</option>
                                                        <option value="2">女</option>
                                                        <elseif condition="$userinfo.gender eq 2" />
                                                        <option value="1">男</option>
                                                        <option value="2" selected>女</option>
                                                        <else />
                                                        <option value="">选择性别</option>
                                                        <option value="1">男</option>
                                                        <option value="2">女</option>
                                                    </if>
                                                </select>
                                                <span data-valmsg-for="gender" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*出生日期：</label>

                                            <div class="form-inline col-xs-8">
                                                <input type="hidden" name="birthday" id="birthday" value="{$userinfo.birthday|datetimeToStr='Y-m-d',###}" />
                                                <select id="ddlYears" name="birthdayYear" class="form-control birthday text-nowrap" style="width:80px;padding:3px;" data-val="true" data-val-grequired-value="birthday" data-val-grequired="此处未选择"></select>
                                                &nbsp;年&nbsp;
                                                <select id="ddlMonths" name="birthdayMonth" class="form-control birthday text-nowrap" style="width:80px;padding:3px;"></select>
                                                &nbsp;月&nbsp;
                                                <select id="ddlDays" name="birthdayDay" class="form-control birthday text-nowrap" style="width:80px;padding:3px;"></select>
                                                &nbsp;日<br />
                                                <span data-valmsg-for="birthdayYear" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <select name="f_birthday" class="form-control">
                                            <option value="1"<if condition="$priArr['f_birthday'] eq 1">selected="selected"</if>>仅自己可见</option>
                                            <option value="2"<if condition="$priArr['f_birthday'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                            <option value="3"<if condition="$priArr['f_birthday'] eq 3">selected="selected"</if>>所有人可见</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*当前所在地：</label>
                                            <div class="col-xs-8 form-inline">
                                                <input type="hidden" name="address" id="address" value="{$userinfo.address}" />
                                                <select name="province" id="ddlProvince" class="form-control addresses" data-val="true" data-val-grequired-value="addresses" data-val-grequired="地址不能为空"></select>
                                                <select name="city" id="ddlCity" class="form-control addresses" style="width:123px;">
                                                    <option value="">请选择</option>
                                                </select>
                                                <span data-valmsg-for="province" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*职业：</label>
                                            <div class="col-xs-8">
                                                <input type="text" id="job" name="job" value="{$userinfo.job}" data-val="true" data-val-required="职业不能为空" class="form-control" maxlength="10" />
                                                <span data-valmsg-for="job" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*工作年限：</label>
                                            <div class="col-xs-8">
                                                <input type="text" id="exp" name="exp" class="form-control" value="{$userinfo.exp}" maxlength="2" data-val="true" data-val-required="工作年限不能为空" />
                                                <span data-valmsg-for="exp" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*手机：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="mobile" name="mobile"
                                                       data-val="true" data-val-required="电话号码不能为空"
                                                       data-val-regex="无效电话号码" data-val-regex-pattern="^(1[34587])[0-9]\\d{8}$" value="{$userinfo.mobile}" maxlength="11" />
                                                <span data-valmsg-for="mobile" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">毕业院校：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="school" name="school" value="{$userinfo.school}" maxlength="20" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <select name="f_school" class="form-control">
                                            <option value="1"<if condition="$priArr['f_major'] eq 1">selected="selected"</if>>仅自己可见</option>
                                            <option value="2"<if condition="$priArr['f_major'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                            <option value="3"<if condition="$priArr['f_major'] eq 3">selected="selected"</if>>所有人可见</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*所学专业：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="major" name="major" value="{$userinfo.major}" maxlength="20" data-val="true" data-val-required="所学专业不能为空" />
                                                <span data-valmsg-for="major" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">*学历：</label>
                                            <div class="col-xs-8">
                                                <select id="xueli" name="xueli" class="form-control" data-val="true" data-val-required="学历不能为空">
                                                    <!-- 数据读字典表 -->
                                                    <option value="">--请选择--</option>
                                                    <volist name="degrees" id="vo">
                                                        <option value="{$vo.id}"<if condition="($vo.id eq $userinfo['xueli'])"> selected </if> >{$vo.name}</option>
                                                    </volist>
                                                </select>
                                                <span data-valmsg-for="xueli" data-valmsg-replace="true"></span>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">擅长领域：</label>
                                            <div class="col-xs-8">
                                                <select id="shanchang" class="form-control" name="shanchang">
                                                    <!-- 数据读字典表 -->
                                                    <option value="0">--请选择--</option>
                                                    <volist name="majors" id="vo">
                                                        <option value="{$vo.id}"<if condition="($vo.id eq $userinfo['shanchang'])"> selected </if>>{$vo.name}</option>
                                                    </volist>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">博客：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="blog" name="blog" value="{$userinfo.blog}" maxlength="30" placeholder="可填写诸如网易lofter主页地址" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <select name="f_blog" class="form-control">
                                            <option value="1"<if condition="$priArr['f_blog'] eq 1">selected="selected"</if>>仅自己可见</option>
                                            <option value="2"<if condition="$priArr['f_blog'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                            <option value="3"<if condition="$priArr['f_blog'] eq 3">selected="selected"</if>>所有人可见</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-9">
                                        <div class="form-group">
                                            <label class="control-label col-xs-4">微博：</label>
                                            <div class="col-xs-8">
                                                <input type="text" class="form-control" id="weibo" name="weibo" value="{$userinfo.weibo}" maxlength="30" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-xs-3">
                                        <select name="f_weibo" class="form-control">
                                            <option value="1"<if condition="$priArr['f_weibo'] eq 1">selected="selected"</if>>仅自己可见</option>
                                            <option value="2"<if condition="$priArr['f_weibo'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                            <option value="3"<if condition="$priArr['f_weibo'] eq 3">selected="selected"</if>>所有人可见</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-xs-12 text-center">
                                        <button type="submit" class="btn btn-success" id="btnSaveBaseInfo">保存</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <br />
                <br />
                <div class="section">
                    <div class="section-title">
                        <a href="javascript:void(0);" class="info-actions pull-right" id="btnEditIntro" title="编辑"><i class="fa fa-edit"></i></a>&nbsp;个人介绍
                    </div>
                    <div class="section-content">
                        <br />
                        <div id="phPreviewIntro">
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group col-xs-12">
                                        <label class="control-label label-align-left">自我简介</label>
                                        <div>
                                            <p class="form-control-static" id="lblAbout">{$userinfo.about|nl2br}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-12 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_about']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-xs-9">
                                    <div class="form-group col-xs-12">
                                        <label class="control-label label-align-left">技能描述</label>
                                        <div>
                                            <p class="form-control-static" id="lblJineng">{$userinfo.jineng|nl2br}</p>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-3">
                                    <div class="form-group">
                                        <div class="col-xs-12 text-right">
                                            <p class="form-control-static"><span class="label-privacy">{$priArr['f_jineng']|toPriFlag}</span></p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="phEditableIntro" style="display:none;">
                            <form id="formEditIntro" method="post">
                                <div class="form-group">
                                    <label class="control-label">自我简介</label>
                                    <select id="f_about" name="f_about" class="custom-select" style="margin-bottom:5px;">
                                        <option value="1"<if condition="$priArr['f_about'] eq 1">selected="selected"</if>>仅自己可见</option>
                                        <option value="2"<if condition="$priArr['f_about'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                        <option value="3"<if condition="$priArr['f_about'] eq 3">selected="selected"</if>>所有人可见</option>
                                    </select>
                                    <textarea id="about" name="about" class="form-control" rows="10" maxlength="200" placeholder="请您填写简要的自我介绍，比如就职行业、职位、擅长的领域；个人爱好等， 200字以内。">{$userinfo.about}</textarea>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">技能描述</label>
                                    <select id="f_jineng" name="f_jineng" class="custom-select" style="margin-bottom:5px;">
                                        <option value="1"<if condition="$priArr['f_jineng'] eq 1">selected="selected"</if>>仅自己可见</option>
                                        <option value="2"<if condition="$priArr['f_jineng'] eq 2">selected="selected"</if>>队友及雇主可见</option>
                                        <option value="3"<if condition="$priArr['f_jineng'] eq 3">selected="selected"</if>>所有人可见</option>
                                    </select>
                                    <textarea id="jineng" name="jineng" class="form-control" rows="10" maxlength="200" placeholder="请您填写自己的工作技能，比如能否熟练运用PPT、绘图软件PS或者掌握了几门外语等， 200字以内。">{$userinfo.jineng}</textarea>
                                </div>
                                <div class="text-center">
                                    <button type="submit" class="btn btn-success" id="btnSaveIntro">保存</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</block>
<block name="footer_scripts">
    <script type="text/javascript">
        function photoCropCompleted(url) {
            $("#userpic").val(url);
        }
    </script>
    <script type="text/javascript">
        require(["jquery", "jquery.unobtrusive", "libraries/location_cn", "libraries/common", "modules/message"],
            function ($, validator, location, common, messageBox) {
                $.validator.addMethod("grequired", function (value, element, params) {
                    var gname = params['value'];
                    var isValid = true;
                    $("select." + gname).each(function () {
                        if ($(this).val() == "" || $(this).val() == null) {
                            isValid = false;
                            return;
                        }
                    });
                    return isValid;
                }, "此处必填");

                $.validator.unobtrusive.adapters.add("grequired", ['value'], function (options) {
                    options.rules["grequired"] = {
                        value: options.params.value
                    };
                    options.messages["grequired"] = options.message;
                });

                function initCities(province, selected) {
                    if (selected != "" && province != "") {
                        $("#ddlCity option").remove();
                        var selectCities = cities[province];
                        for (var i = 0; i < selectCities.length; i++) {
                            if (selectCities[i] == selected) {
                                $("#ddlCity").append("<option selected value='" + selectCities[i] + "'>" + selectCities[i] + "</option>");
                            } else {
                                $("#ddlCity").append("<option value='" + selectCities[i] + "'>" + selectCities[i] + "</option>");
                            }
                        }
                    }
                }

                $("#btnSavePic").on("click", function () {
                    var photo = $('#userpic').val();
                    if (photo == '') {
                        messageBox.alert({ content: "请先裁剪图片" });
                        return false;
                    }
                    var url = "{:U('User/userphoto_ajax')}";
                    $.post(url, { photo: photo }, function (data) {
                        var vdata = eval(data);
                        if (vdata.success == 1) {
                            messageBox.alert({ content: "保存成功", sure: function () { window.location.reload(); } });
                        }
                    }, 'json');
                    return false;
                });

                $(function () {
                    bindDropDownListData("#ddlYears", 1935, new Date().getFullYear(), onYearChange);
                    bindDropDownListData("#ddlMonths", 1, 12, onYearChange);
                    bindDropDownListData("#ddlDays", 1, 31);
                    $('#ddlDays').change(function () { $('#birthday').val($('#ddlYears option:selected').val() + '-' + $('#ddlMonths option:selected').val() + '-' + $('#ddlDays option:selected').val()); });

                    //初始化所在地选择控件
                    var address = "{$userinfo.address}";
                    var prnAndCity = address.split(',');
                    var province = prnAndCity[0];
                    var city = prnAndCity[1];
                    for (var item in cities) {
                        if (province == item) {
                            $("#ddlProvince").append("<option selected value='" + item + "'>" + item + "</option>");
                        } else {
                            $("#ddlProvince").append("<option value='" + item + "'>" + item + "</option>");
                        }
                    }
                    initCities(province, city);

                    $("#ddlProvince").change(function () {
                        initCities($(this).val());
                        $("#address").val($("#ddlProvince").val() + "," + $("#ddlCity").val());
                    });
                    $("#ddlCity").change(function () {
                        $("#address").val($("#ddlProvince").val() + "," + $("#ddlCity").val());
                    });

                    //初始化生日数据
                    var birthday = $('#birthday').val();
                    var dateArray = birthday.split('-');
                    var year = dateArray[0];
                    var mon = parseInt(dateArray[1]);
                    var day = parseInt(dateArray[2]);
                    if (year && year != "未填写") {
                        $('#ddlYears').val(year);
                    }
                    if (mon) {
                        $('#ddlMonths').val(mon);
                    }
                    if (day) {
                        $('#ddlDays').val(day);
                    }

                    $("#btnEditPic").click(function () {
                        if ($(this).attr("title") == "编辑") {
                            $(this).attr("title", "取消");
                            $(this).html("<i class='fa fa-times'></i>");
                            $("#phPreviewPic").hide();
                            $("#phEditablePic").fadeIn();
                            $("#nickname").focus();
                        } else {
                            $(this).attr("title", "编辑");
                            $(this).html("<i class='fa fa-edit'></i>");
                            $("#phPreviewPic").fadeIn();
                            $("#phEditablePic").hide();
                        }
                    });

                    $("#btnEditBaseInfo").click(function () {
                        if ($(this).attr("title") == "编辑") {
                            $(this).attr("title", "取消");
                            $(this).html("<i class='fa fa-times'></i>");
                            $("#phPreviewBaseInfo").hide();
                            $("#phEditableBaseInfo").fadeIn();
                            $("#nickname").focus();
                        } else {
                            $(this).attr("title", "编辑");
                            $(this).html("<i class='fa fa-edit'></i>");
                            $("#phPreviewBaseInfo").fadeIn();
                            $("#phEditableBaseInfo").hide();
                        }
                    });

                    $("#btnEditIntro").click(function () {
                        if ($(this).attr("title") == "编辑") {
                            $(this).attr("title", "取消");
                            $(this).html("<i class='fa fa-times'></i>");
                            $("#phPreviewIntro").hide();
                            $("#phEditableIntro").fadeIn();
                        } else {
                            $(this).attr("title", "编辑");
                            $(this).html("<i class='fa fa-edit'></i>");
                            $("#phPreviewIntro").fadeIn();
                            $("#phEditableIntro").hide();
                        }
                    });

                    $("#formBaseInfo").submit(function () {
                        if (!$("#formBaseInfo").valid()) {
                            return false;
                        }
                        var postData = $("#formBaseInfo").serialize();
                        $.ajax({
                            url: "{:U('User/userinfo_ajax')}",
                            data: postData,
                            dataType: "json",
                            type: "post",
                            success: function (data) {
                                if (data.success != 1) {
                                    messageBox.alert({ title: "保存失败", content: data.msg, sure: function () { window.location.reload(); } });
                                } else {
                                    window.location.reload();
                                }
                            }
                        });
                        return false;
                    });


                    $("#btnSaveIntro").click(function () {
                        if (!$("#formEditIntro").valid()) {
                            return false;
                        }
                        var postData = { 'about': $('#about').val(), 'f_about': $('#f_about').val(), 'jineng': $('#jineng').val(), 'f_jineng': $('#f_jineng').val() };
                        $.ajax({
                            url: "{:U('User/userabout_ajax')}",
                            data: postData,
                            dataType: "json",
                            type: "post",
                            success: function (data) {
                                if (data.success != 1) {
                                    messageBox.alert({ title: "保存失败", content: data.msg, sure: function () { window.location.reload(); } });
                                } else {
                                    window.location.reload();
                                }
                            }
                        });
                        return false;
                    });

                });


                function savePhoto() {

                }


                function onYearChange(e) {
                    var year = $("#ddlYears :selected").val();
                    var month = $("#ddlMonths :selected").val();
                    if (year != "" && month != "") {
                        var selected = new Date(year, month - 1);
                        bindDropDownListData("#ddlDays", 1, selected.daysInMonth());
                        $('#birthday').val($('#ddlYears option:selected').val() + '-' + $('#ddlMonths option:selected').val() + '-' + $('#ddlDays option:selected').val());
                    }
                }


            });
    </script>
</block>